import {
  Column,
  CreateDateColumn,
  Entity,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';

export enum WorkTypes {
  ORDER = 'order',
  PRODUCT = 'product',
  FEEDBACK = 'feedback',
}

export enum WorkStatus {
  // 待处理
  PENDING = 'pending',
  // 处理中
  HANDING = 'handing',
  // 已完成
  COMPLETED = 'completed',
  // 已关闭
  CLOSED = 'closed',
}

@Entity('tb_work', {
  comment: '工单表',
})
export class Work {
  @PrimaryGeneratedColumn('increment', { comment: '自增主键', unsigned: true })
  id: number;

  @Column({ comment: '工单编号', unique: true })
  no: string;

  @Column({ comment: '客服ID' })
  clerkId: number;

  @Column({ comment: '工单类型', default: WorkTypes.ORDER })
  type: WorkTypes;

  @Column({ comment: '工单描述' })
  description: string;

  @Column({ comment: '工单状态' })
  status: WorkStatus;

  @Column({ comment: '处理进程' })
  process: string;

  @CreateDateColumn({ comment: '创建时间' })
  created: Date;

  @UpdateDateColumn({ comment: '更新时间' })
  updated: Date;
}
